package hoddler

import (
	"github.com/gin-gonic/gin"
	"zy10/reportily"
	"zy10/request"
	"zy10/response"
)

func AddFriend(c *gin.Context) {
	var req request.AddFriend
	err := c.ShouldBind(&req)
	if err != nil {
		response.ResponseError(c, "错误", err.Error())
		return
	}
	addfinly, err := reportily.Addfinly(req.UserTwoId)
	if addfinly.Id == 0 {
		response.ResponseError(c, "申请用户不存在", err)
		return
	}
	friend, err := reportily.AddFriend(c.GetUint("userId"), req.UserTwoId, req.Status)
	if friend.Id == 0 {
		response.ResponseError(c, "发送添加请求失败", err)
		return
	}
	response.ResponseSuccess(c, "发送请求成功", friend)
}
